#!/bin/sh
#
# generateLocalSSHKey.sh
#

if [ $# != 1 ];then
  echo "Usage: generateLocalSSHKey.sh username"
  exit 1;
fi

username=$2

su $username -c "if [ -e ~/.ssh/id_rsa ];then rm ~/.ssh/id_rsa; fi && ssh-keygen -t rsa -f ~/.ssh/id_rsa -N '' -q"
	
result=$?

if [ $result -ne 0 ]; then
	exit $result
fi

exit 0
